package com.speech.net.entity;

import android.app.Activity;
import android.content.Context;

import com.speech.constant.PrefsConstant;
import com.speech.db.SharedPreferenceHelper;
import com.speech.net.constant.EnumDeviceType;
import com.speech.net.constant.EnumReqestActionCode;
import com.speech.utils.ApkVersionUtil;
import com.speech.utils.DeviceUtil;

public class MessageC2SBuilder {

    public static MessageC2S buildGeneral_MessageC2S(Context context, EnumReqestActionCode reqestActionCode, String strData) {
        MessageC2S msg = new MessageC2S();
        msg.enumDeviceType = EnumDeviceType.ANDROID;
        msg.strDeviceID = DeviceUtil.getDeviceID((Activity) context);
        msg.strVersion = ApkVersionUtil.getVersionName(context);
        msg.reqestAction = reqestActionCode;
        msg.strData = strData;

        SharedPreferenceHelper spf = new SharedPreferenceHelper(context, PrefsConstant.FILE_USER_INFO);
        Long lUID = (Long) spf.getData(PrefsConstant.KEY_USER_INFO_LONG_UID, SharedPreferenceHelper.LONG_TYPE_DEFAULT);
        if (lUID != SharedPreferenceHelper.LONG_TYPE_DEFAULT) {
            msg.lUserID = lUID;
        }
        Long lToken = (Long) spf.getData(PrefsConstant.KEY_USER_INFO_LONG_TOKEN, SharedPreferenceHelper.LONG_TYPE_DEFAULT);
        if (lToken != SharedPreferenceHelper.LONG_TYPE_DEFAULT) {
            msg.lUserToken = lToken;
        }

        return msg;
    }


}
